﻿<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../helpproject.xsl" ?>
<topic template="Default" status="Under Construction" lasteditedby="Geert" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../helpproject.xsd">
  <title translate="true">Creating user controls</title>
  <keywords>
    <keyword translate="true">MVVM</keyword>
    <keyword translate="true">UserControl</keyword>
    <keyword translate="true">UserControl&lt;TViewModel&gt;</keyword>
  </keywords>
  <body>
    <header>
      <para styleclass="Heading1"><text styleclass="Heading1" translate="true">Creating user controls</text></para>
    </header>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">A nice thing about the .NET framework is the support for controls. This way, it is possible to split up a bit of logic into a reusable component called </text><text styleclass="Normal" style="font-style:italic;" translate="true">UserControl</text><text styleclass="Normal" style="font-style:italic; text-decoration:none;" translate="true">. </text><text styleclass="Normal" style="font-style:normal; text-decoration:none;" translate="true">However, there are no MVVM frameworks/toolkits besides Catel that allow you to create user controls using the MVVM pattern. Is this a reason to stop using user controls? No it&apos;s not, and this part of the documentation will guide you through the process of creating your own user control.</text></para>
    <para styleclass="Heading1"><text styleclass="Heading1" style="font-style:normal; text-decoration:none;" translate="true">Creating the view model</text></para>
    <para styleclass="Normal"><text styleclass="Normal" style="font-style:normal; text-decoration:none;" translate="true">First, it is important to think about the view model lifetime. Do you want the view model to be constructed only when there is a valid </text><text styleclass="Normal" style="font-style:italic; text-decoration:none;" translate="true">DataContext</text><text styleclass="Normal" style="font-style:normal; text-decoration:none;" translate="true">, or should there be an instance of the view model at all times?</text></para>
    <para styleclass="Normal"></para>
    <para styleclass="Heading1"><text styleclass="Heading1" style="font-style:normal; text-decoration:none;" translate="true">Creating the user control</text></para>
    <para styleclass="Normal"></para>
    <para styleclass="Heading1"><text styleclass="Heading1" style="font-style:normal; text-decoration:none;" translate="true">Adding mappings for the dependency properties</text></para>
    <para styleclass="Normal"></para>
  </body>
</topic>
